#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<functional>
#include<iterator>
using namespace std;


int main()
{
		int array[]={26,17,15,22,33,31,40};

		vector<int> ivec(array,array+sizeof(array)/sizeof(int));

		copy(ivec.begin(),ivec.end(),ostream_iterator<int> (cout," "));

		cout<<*max_element(ivec.begin(),ivec.end());
		cout<<*max(ivec.begin(),ivec.end());

		vector<int> vec2(10);

		partial_sort_copy(ivec.begin(),ivec.begin()+3,vec2.begin(),vec2.begin()+3);
		copy(vec2.begin(),vec2.end(),ostream_iterator<int> (cout," "));
		cout<<endl;

		
		partial_sort_copy(ivec.begin(),ivec.end(),vec2.begin(),vec2.end());
		cout<<binary_search(vec2.begin(),vec2.end(),15)<<endl;
		cout<<endl;


		next_permutation(ivec.begin(),ivec.end());
		copy(ivec.begin(),ivec.end(),ostream_iterator<int> (cout," "));
		cout<<endl;
		next_permutation(ivec.begin(),ivec.end());
		copy(ivec.begin(),ivec.end(),ostream_iterator<int> (cout," "));
		cout<<endl;


		nth_element(ivec.begin(),ivec.begin()+3,ivec.end());
		copy(ivec.begin(),ivec.end(),ostream_iterator<int> (cout," "));
		cout<<endl;

		vector<int> vec3(ivec.size()+vec2.size());

		copy(ivec.begin(),ivec.end(),ostream_iterator<int> (cout," "));
		cout<<endl;
		copy(vec2.begin(),vec2.end(),ostream_iterator<int> (cout," "));
		cout<<endl;
		merge(ivec.begin(),ivec.end(),vec2.begin(),vec2.end(),vec3.begin());
		copy(vec3.begin(),vec3.end(),ostream_iterator<int> (cout," "));
		cout<<endl;


}
